package com.jsyh.maidu.utils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.jsyh.maidu.R;

/**
 * Created by ZHY_9 on 2017/7/21.
 */

public class MenuPopupWindow implements View.OnClickListener{

    private Context context;
    private PopupWindow pop;


    public MenuPopupWindow(Context context) {
        this.context = context;
        View view = LayoutInflater.from(context).inflate(R.layout.menu_pop, null);
        pop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
//        pop.setOutsideTouchable(true);
        view.findViewById(R.id.pop_home).setOnClickListener(this);
        view.findViewById(R.id.pop_category).setOnClickListener(this);
        view.findViewById(R.id.pop_shop_cart).setOnClickListener(this);
        view.findViewById(R.id.pop_me).setOnClickListener(this);
    }

    public void show(View targetView) {
        pop.showAsDropDown(targetView, 0, 0);
    }

    public boolean isShowing(){
        return pop.isShowing();
    }

    public void hide(){
        if (pop != null){
            pop.dismiss();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.pop_home:

                break;
            case R.id.pop_category:

                break;
            case R.id.pop_shop_cart:

                break;
            case R.id.pop_me:

                break;
        }
    }
}
